package com.laoniu.generator;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class GeneratorCode {

    public static void main(String[] args) {
        new GeneratorCode().generator();
    }

    public void generator(){
        FastAutoGenerator.create("jdbc:mysql://localhost:3306/stock?characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC", "root", "123456")
                .globalConfig( builder -> {
                    builder.author("lxl")
                            .outputDir("E:\\学习\\开源项目\\网约车\\stockback\\stock-web\\src\\main\\java");
                })
                .packageConfig(builder -> {
                    builder.parent("com.laoniu")
                            .moduleName("")
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "E:\\学习\\开源项目\\网约车\\stockback\\stock-web\\src\\main\\resources\\mappers"));
                })
                .strategyConfig(builder -> {
                    builder.addInclude("goods_stock,goods_return,goods_sale,goods_sale_return")
                            .addTablePrefix("","");
                })
                .templateEngine(new FreemarkerTemplateEngine())
                .execute();
    }
}
